﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CH04_01
{
    public class clsStudent
    {
        // 定义私有字段;
        private int iAge;

        // 属性声明,用于对私有字段的访问;
        public int Age
        {
            get
            {
                return this.iAge;
            }
            set
            {
                if (value != this.iAge)
                {
                    this.iAge = value;
                }
            }
        }
        static void Main(string[] args)
        {
            clsStudent s = new clsStudent();
            s.Age = 20;
            Console.WriteLine(s.Age);
        }
    }
}
